package com.shennan.eduService.controller;


import com.shennan.commonutils.R;
import com.shennan.eduService.entity.subject.OneSubject;
import com.shennan.eduService.service.EduSubjectService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author sn
 * @since 2021-01-09
 */
@Api(description="课程分类管理")
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    //1、添加课程分类
    //获取上传文件，把文件内容读出来
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        //上传excel文件
        subjectService.saveSubject(file, subjectService);
        return R.ok();
    }

    @GetMapping("getAllSubject")
    public R getAllSubject(){
        List<OneSubject> list = subjectService.getAllOneTwoSubject();
        return R.ok().data("list", list);
    }
}

